<?php
    // get product 

    $where = "";
    if(isset($_GET['var2']))
            $where = " where titleurl = '".$_GET['var2']."' ";

    $re_product = $db->select("select * from product_item $where order by orderId asc, id asc limit 1 ");
    $tt_product = $db->fetch($re_product);
    
    $where_cat = " where id = " . $tt_product['idcat'];
 
    $re_cat = $db->select("select * from product_cat $where_cat  order by orderId asc, id asc limit 1 ");
    $tt_cat = $db->fetch($re_cat);
?>
<div class="left-col">
	<div class="title fsize17"><?= $co_product['titlemenu'.$hg] ?></div>	
	<ul class="pl-list">
		<?php
		$re_list = $db->select("select * from product_cat where level = 1 order by orderId asc");
		while($tt_list = $db->fetch($re_list))
		{
			if(($act=="product" || $act=="product-detail" ) && $tt_list['id'] == $tt_cat['id'])
				$subClass = "active";
			else 
				$subClass = "";
		?>
		<li class="<?= $subClass ?>">
                    <a href="<?=APPLICATION_URL?>product/<?=$tt_list['titleurl']?>.html"><?=$tt_list['title'.$hg]?></a>
                    
                    <ul>
                        <?php
                        $re_list2 = $db->select("select * from product_cat where level = 2 and parentid=".$tt_list['id']." order by orderId asc");
                        while($tt_list2 = $db->fetch($re_list2))
                        {
                                if(($act=="product" || $act=="product-detail" ) && $tt_list2['id'] == $tt_cat['id'])
                                        $subClass2 = "active";
                                else 
                                        $subClass2 = "";
                        ?>
                        <li class="<?= $subClass2 ?>">
                            <a href="<?=APPLICATION_URL?>product/<?=$tt_list2['titleurl']?>.html"><?=$tt_list2['title'.$hg]?></a>
                            <ul>
                                <?php
                                $re_list3 = $db->select("select * from product_cat where level = 3 and parentid=".$tt_list2['id']." order by orderId asc");
                                while($tt_list3 = $db->fetch($re_list3))
                                {
                                        if(($act=="product" || $act=="product-detail" ) && $tt_list3['id'] == $tt_cat['id'])
                                                $subClass3 = "active";
                                        else 
                                                $subClass3 = "";
                                ?>
                                <li class="<?= $subClass3 ?>">
                                    <a href="<?=APPLICATION_URL?>product/<?=$tt_list3['titleurl']?>.html"><?=$tt_list3['title'.$hg]?></a>
                                </li>
                                <?php } ?>
                                
                            </ul>
                        </li>
                        
                        <?php } ?>
                    </ul>
		</li>
		<?php
		}
		?>
		
	</ul>
</div>
<?php			
	$where_item = " where idcat = '".$tt_cat['id']."' ";
	if(isset($_GET['var3']))	
		$where_item .= " and titleurl = '".$_GET['var3']."' ";
	
	$re_item = $db->select("select * from product_item $where_item  order by orderId asc, id asc limit 1 ");
	$tt_item = $db->fetch($re_item);
?>
<div class="right-col">
	<div class="title"><?= $tt_cat['title'.$hg] ?></div>
	<?php if(!empty($tt_cat['image'])): ?>
	<img style="margin-bottom:20px;" class="cat-image" src="<?=APPLICATION_URL?>product-img/<?=$tt_cat['image']?>">
	<?php endif; ?>
	
	<div class="content-text product-detail-ctn">
		<div class="proimg">
			<img src="<?=APPLICATION_URL?>product-img/list/<?=$tt_item['image']?>" alt="">
		</div>
		<div class="title-desc">
			<h1 class="title"><?= $tt_item['title'.$hg] ?></h1>
			<div class="desc">
				<?= $tt_item['description'.$hg] ?>
			</div>
		</div>
		<div class="clear"></div>
                <div class="product-content">
                    <?= $tt_item['content'] ?>
                </div>
	</div>
</div>
